package cn.yuanqiao.web.controller.archive.identification;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.identification.domain.IdentificationRecord;
import cn.yuanqiao.archive.identification.service.IIdentificationRecordService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 识别记录Controller
 * 
 * @author xy
 * @date 2023-10-12
 */
@RestController
@RequestMapping("/archive/identification")
public class IdentificationRecordController extends BaseController
{
    @Autowired
    private IIdentificationRecordService identificationRecordService;

    /**
     * 查询识别记录列表
     */

    @PreAuthorize("@ss.hasPermi('archive:fileCollection:identifyRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(IdentificationRecord identificationRecord)
    {
        startPage();
        List<IdentificationRecord> list = identificationRecordService.selectIdentificationRecordList(identificationRecord);
        return getDataTable(list);
    }

    /**
     * 导出识别记录列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:identification:export')")
*/
    @Log(title = "识别记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IdentificationRecord identificationRecord)
    {
        List<IdentificationRecord> list = identificationRecordService.selectIdentificationRecordList(identificationRecord);
        ExcelUtil<IdentificationRecord> util = new ExcelUtil<IdentificationRecord>(IdentificationRecord.class);
        util.exportExcel(response, list, "识别记录数据");
    }

    /**
     * 获取识别记录详细信息
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:identification:query')")
*/
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(identificationRecordService.selectIdentificationRecordById(id));
    }

    /**
     * 新增识别记录
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:identification:add')")
*/
    @Log(title = "识别记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IdentificationRecord identificationRecord)
    {
        return toAjax(identificationRecordService.insertIdentificationRecord(identificationRecord));
    }

    /**
     * 修改识别记录
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:identification:edit')")
*/
    @Log(title = "识别记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IdentificationRecord identificationRecord)
    {
        return toAjax(identificationRecordService.updateIdentificationRecord(identificationRecord));
    }

    /**
     * 删除识别记录
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:identification:remove')")
*/
    @PreAuthorize("@ss.hasPermi('archive:sbjl:delete')")
    @Log(title = "识别记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(identificationRecordService.deleteIdentificationRecordByIds(ids));
    }
}
